//
// Created by TheHun on 2021/6/17.
//

#include "offlineRelay.h"

LineRelayMetaInfo* NewLineRelayMetaInfo(char* deviceName,
        Device* local,
        Device* remote,
        char* fileName,
        int portCount,
        const int* portSize,
        int tripSize) {
    LineRelayMetaInfo* meta = (LineRelayMetaInfo*)malloc(sizeof(LineRelayMetaInfo));
    meta->deviceName = deviceName;
    meta->relayFunc = lineRelay;
    meta->dataFileName = fileName;
    meta->localDevice = local;
    meta->remoteDevice = remote;
    meta->portCount = portCount;
    meta->portSize = (int*)malloc(sizeof(int) * portCount);
    for (int i = 0; i < portCount; i++) {
        meta->portSize[i] = portSize[i];
    }
    meta->tripSize = tripSize;
    return meta;
}

void lineRelay(char* deviceName, Device* localDevice, Device* remoteDevice, double* time, double* port1, double* port2, double* tripSignal) {
    globalInit();
    lineLinkSimulation(localDevice, remoteDevice, deviceName, *time, 1, port1, port2, tripSignal);
}

